package secret.santa.server;

import javax.jdo.PersistenceManager;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import secret.santa.client.CS_EventEntry;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DB_EventEntry
{
	public DB_EventEntry()
	{
		wishList = "Not filled in yet.";
	}
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
	private String encodedKey;
	
	@Persistent
	private String eventKey;
	
	@Persistent
	private String keyFrom;
	
	@Persistent
	private String keyTo;
	
	@Persistent
	private String wishList;

	public CS_EventEntry toClient()
	{
		CS_EventEntry c = new CS_EventEntry();
		PersistenceManager pm = PMF.get().getPersistenceManager();
		
		c.eventKey = eventKey;
		c.from = pm.getObjectById(DB_User.class, keyFrom).getFullName();
		c.to =  pm.getObjectById(DB_User.class, keyTo).getFullName();
		c.wishList = wishList;
		pm.close();
		return c;
	}
	/**
	 * @param wishList the wishList to set
	 */
	public void setWishList(String wishList) {
		this.wishList = wishList;
	}

	/**
	 * @return the wishList
	 */
	public String getWishList() {
		return wishList;
	}

	/**
	 * @param eventKey the eventKey to set
	 */
	public void setEventKey(String eventKey) {
		this.eventKey = eventKey;
	}

	/**
	 * @return the eventKey
	 */
	public String getEventKey() {
		return eventKey;
	}

	/**
	 * @param keyFrom the keyFrom to set
	 */
	public void setKeyFrom(String keyFrom) {
		this.keyFrom = keyFrom;
	}

	/**
	 * @return the keyFrom
	 */
	public String getKeyFrom() {
		return keyFrom;
	}

	/**
	 * @param keyTo the keyTo to set
	 */
	public void setKeyTo(String keyTo) {
		this.keyTo = keyTo;
	}

	/**
	 * @return the keyTo
	 */
	public String getKeyTo() {
		return keyTo;
	}
	/**
	 * @param encodedKey the encodedKey to set
	 */
	public void setEncodedKey(String encodedKey) {
		this.encodedKey = encodedKey;
	}
	/**
	 * @return the encodedKey
	 */
	public String getEncodedKey() {
		return encodedKey;
	}

}
